home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource1 / cenvid / keystuff.bat < prev    next >
DOS Batch File  |  1993-09-27  |  2KB  |  65 lines

  1. @echo off
  2. REM KeyStuff.bat - Stuff characters into the keyboard buffer
  3.  
  4. SET THISFILE=%0
  5. SET KEYSTUFFS='
  6. :BUILD_KEYSTUFFS
  7. IF "%1" == "" GOTO END_BUILD
  8. IF "%KEYSTUFFS%" == "" SET KEYSTUFFS=%1
  9. IF NOT "%KEYSTUFFS%" == "" SET KEYSTUFFS=%KEYSTUFFS% %1
  10. SHIFT
  11. GOTO BUILD_KEYSTUFFS
  12. :END_BUILD
  13. SET KEYSTUFFS=%KEYSTUFFS%'
  14.  
  15. CEnvi %THISFILE%.bat %KEYSTUFFS%
  16. GOTO CENVI_EXIT
  17.  
  18. #define NEXT_CHAR_PTR      0x41A
  19. #define LAST_CHAR_PTR      0x41C
  20. #define KYBD_BUF_START_PTR 0x480
  21. #define KYBD_BUF_END_PTR   0x482
  22. #define DOS_STATIC_MEMORY  0x400
  23.  
  24. main(argc,argv)
  25. {
  26.    if ( !strcmpi(argv[1],"\'/?\'") ||  !strcmpi(argv[1],"\'\'") )
  27.       Instructions();
  28.    else {
  29.  
  30.       // get start and end address of the keyboard buffer
  31.       BufStart = peek(KYBD_BUF_START_PTR,UWORD16);
  32.       BufEnd = peek(KYBD_BUF_END_PTR,UWORD16) - 2;
  33.  
  34.       // Poke bytes from input arguments into the keyboard buffer
  35.       BufLen = min((BufEnd - BufStart)/2,1+GetArraySpan(KEYSTUFFS));
  36.       for ( Addr = BufStart, c = KEYSTUFFS; BufLen--; Addr += 2, c++ )
  37.          poke(Addr+DOS_STATIC_MEMORY,c[0]);
  38.  
  39.       // save pointers to beginning and ending of buffer
  40.       poke(NEXT_CHAR_PTR,BufStart,UWORD16);
  41.       poke(LAST_CHAR_PTR,Addr,UWORD16);
  42.  
  43.    }
  44. }
  45.  
  46. Instructions()
  47. {
  48.    printf("\a");
  49.    printf("KeyStuff - Push characters into the keyboard buffer\n");
  50.    printf("\n");
  51.    printf("USAGE: KeyStuff String\n");
  52.    printf("  Where String is fifteen or fewer bytes for the keyboard buffer\n");
  53.    printf("\n");
  54.    printf("EXAMPLE:  The following batch file would start up BASIC.COM with the initial\n");
  55.    printf("          command: Load \"Truck\"\n");
  56.    printf("                call KeyStuff Load\\x20\\\"Truck\\\"\\r\\n\n");
  57.    printf("                basica.com\n");
  58.    printf(" \n");
  59. }
  60.  
  61. :CENVI_EXIT
  62. SET THISFILE=
  63. SET KEYSTUFFS=
  64.  
  65.